#!/bin/sh
# PX4 commands need the 'px4-' prefix in bash.
# (px4-alias.sh is expected to be in the PATH)
. px4-alias.sh

param select parameters.bson
param import

# system_power not implemented
param set CBRK_SUPPLY_CHK 894281

param set-default BAT1_V_DIV 5.7

# broadcast to LAN
# always keep current config
param set SYS_AUTOCONFIG 0
# useless but required for parameter completeness
param set MAV_TYPE 2
param set SYS_AUTOSTART 4001

dataman start

load_mon start

battery_status start

# internal IMU
if ! icm42688p start -q -s -R 4
then
	# some boards has ICM42605 instead
	icm42605 start -s -R 4
fi
if ! ist8310 start -q -I -a 15 -R 4
then
	# some boards has QMC5883l instead
	qmc5883l start -I -R 6
fi
ms5611 start -I

# ADC
ads1115 start -I

# PWM
pca9685_pwm_out start
control_allocator start

# external GPS & compass
gps start -d /dev/ttySC0 -i uart -p ubx -s
#hmc5883 start -X
#ist8310 start -X

rc_input start -d /dev/ttyAMA0

rc_update start
sensors start
commander start
navigator start
ekf2 start
land_detector start multicopter
mc_hover_thrust_estimator start
flight_mode_manager start
mc_pos_control start
mc_att_control start
mc_rate_control start

mavlink start -x -u 14556 -r 1000000 -p

# Telem
mavlink start -x -Z -d /dev/ttySC1

logger start -t -b 200

mavlink boot_complete
